<?php $__env->startSection('content'); ?>
    <div class="admin-content">
        <div class="am-cf am-padding">
            <div class="am-fl am-cf"><strong class="am-text-primary am-text-lg">商品回收站</strong> /
                <small>Products Trash</small>
            </div>
        </div>

<br/>
        <div class="am-g">
            <div class="am-u-sm-12 am-u-md-6">
                <div class="am-btn-toolbar">
                    <div class="am-btn-group am-btn-group-xs">
                        <button type="button" class="am-btn am-btn-default" id="force_destroy_checked">
                            <span class="am-icon-trash-o"></span> 删除
                        </button>
                        <button type="button" class="am-btn am-btn-success" id="restore_checked">
                            <span class="am-icon-reply"></span> 还原
                        </button>
                    </div>
                </div>
            </div>
        </div>

        <div class="am-g">
            <div class="am-u-sm-12">
                <form class="am-form">
                    <table class="am-table am-table-striped am-table-hover table-main">
                        <thead>
                        <tr>
                            <th class="table-check"><input type="checkbox" id="checked"></th>
                            <th class="table-id">编号</th>
                            <th>缩略图</th>

                            <th class="table-title">商品名称</th>
                            <th>单价</th>
                            <th class="table-category">所属分类</th>
                            <th class="table-brand">品牌</th>
                            <th class="table-date am-hide-sm-only">发布日期 / 删除日期</th>
                            <th class="table-set">操作</th>
                        </tr>
                        </thead>
                        <tbody>

                        <?php foreach($products as $product): ?>
                        <tr>
                            <td><input type="checkbox" value="<?php echo e($product->id); ?>" class="checked_id" name="checked_id[]">
                            </td>
                            <td class="product_id"><?php echo e($product->id); ?></td>
                            <td class="product_thumb">
                                <?php if($product->thumb): ?> <img src="<?php echo e($product->thumb); ?>" style="height: 60px" /><?php endif; ?>
                            </td>
                            <td><?php echo e($product->name); ?></td>
                            <td><?php echo e($product->price); ?></td>
                            <td><?php echo e($product->category->name); ?></td>
                            <td></td>
                            <td><?php echo e($product->created_at); ?> / <?php echo e($product->deleted_at); ?></td>

                            <td>
                                <div class="am-btn-toolbar">
                                    <div class="am-btn-group am-btn-group-xs">
                                        <a class="am-btn am-btn-default am-btn-xs am-text-secondary" href="/shop/product/<?php echo e($product->id); ?>/restore">
                                            <span class="am-icon-reply"></span> 还原
                                        </a>
                                        <a class="am-btn am-btn-default am-btn-xs am-text-danger am-hide-sm-only" href="/shop/product/<?php echo e($product->id); ?>/delete_force"
                                           data-method="delete" data-token="<?php echo e(csrf_token()); ?>"  data-confirm="确认删除吗?">
                                            <span class="am-icon-trash-o"></span> 删除
                                        </a>
                                    </div>
                                </div>
                            </td>
                        </tr>
<?php endforeach; ?>
                        </tbody>
                    </table>

                    共 <?php echo e($products->total()); ?> 条记录

                    <div class="am-cf">
                        <div class="am-fr">
                            <?php echo $products->links(); ?>

                        </div>
                    </div>

                </form>
            </div>
        </div>
    </div>
    <?php $__env->stopSection(); ?>

<?php $__env->startSection('js'); ?>
    <script type="text/javascript">
        $(function(){
            $('#checked').click(function(){
                $('.checked_id').prop('checked',this.checked);
            })

            //多选恢复 用ajax实现
            $('#restore_checked').click(function(){
                var length=$('.checked_id:checked').length;
                if (length == 0) {
                    alert("您必须至少选中一条!");
                    return false;
                }

                //关键是获得要恢复的数组
                var ids='';
                $(".checked_id:checked").each(function(){
                    ids+=$(this).val()+' ';
                })
                console.log(ids);

                $.ajax({
                    url:'/shop/product/restore_checked',
                    type:'get',
                    data:{ids:ids},
                    success:function(data){
                        console.log(data);
                        location.href = location.href+'?'+Math.random();
                    }
                })
            })
            //回收站多选删除没做！
            $('#force_destroy_checked').click(function(){
                alert('回收站多选删除没做！')
            })
        })
    </script>
    <?php $__env->stopSection(); ?>
<?php echo $__env->make('admin.layouts.app', array_except(get_defined_vars(), array('__data', '__path')))->render(); ?>